# TODO: Add comment
# 
# Author: phamha
###############################################################################

#mod_linear_4np
regress_predict = function(sate_data,model_type,cook_type,aod,temp,avg_temp,avg_rh,avg_preci){
	if(sate_data=="mod"&&model_type=="linear"&&cook_type=="4np"){
		pm25 = 22.58132724* aod + 0.08452807 * temp + (-2.98371028)*avg_temp + (-0.58041657)*avg_rh + 0.64525692 * avg_preci + 113.98273058
	}
	if(sate_data=="mod"&&model_type=="linear"&&cook_type=="fdist"){
		pm25 = 29.3009026972483* aod - 0.0121947942915479 * temp + (-4.05178592218209)*avg_temp + (-1.17578020320201)*avg_rh + 1.01861037054962 * avg_preci + 213.045850613292
	}
	if(sate_data=="myd"&&model_type=="linear"&&cook_type=="4np"){
		pm25 = 25.6965586 * aod + 0.1525928 * temp + (-2.1894375)*avg_temp + (-0.6837351)*avg_rh + 0.4189560 * avg_preci + 70.1740458
	}
	if(sate_data=="myd"&&model_type=="linear"&&cook_type=="fdist"){
		pm25 = 30.5744605532908 * aod + 0.118323308557864 * temp + (-2.47362345170908)*avg_temp + (-0.795065245241148)*avg_rh + 0.45323741215544 * avg_preci + 94.9758204191974
	}
	
	return(pm25)
}
#get data from DB
getDataFromDB = function(sql_command){
	driver = dbDriver("PostgreSQL")
	connect = dbConnect(driver,dbname = database_name,host = host_name,port=5432,user = user_name,password= password)
	rs = dbSendQuery(connect,sql_command)
	data=fetch(rs,n=-1)
	return (data)
}
